resource = {}
resource["host"] = 0
resource["nfc0"] = 0
resource["nfc1"] = 0
resource["nfc2"] = 0
resource["nfc3"] = 0
resource["matcher1"] = 0
resource["matcher2"] = 0

resource["arm"] = 0

buffer_size = 2
write_back_time = 600
arm_time = 150

nfc_count = len(list(filter(lambda x:True if "nfc" in x else False,list(resource))))
matcher_count = len(list(filter(lambda x:True if "matcher" in x else False,list(resource))))

#(操作序号，操作资源，时间，前置任务依赖)
# read1 = ["读1",(1,"nfc1",100,(0,)),(2,"nfc1",100,(1,)),(3,"host",20,(2,)),(4,"host",5,(3,))]
# read2 = ["读2",(1,"nfc2",100,(0,)),(2,"nfc2",100,(1,)),(3,"host",20,(2,)),(4,"host",5,(3,))]
# write1 = ["写",(1,"nfc1",100,(0,)),(2,"nfc1",100,(1,)),(3,"host",20,(2,)),(4,"nfc1",600,(3,)),(5,"host",5,(4,))]
# text1 = ["文本",(1,"host",20,(0,)),(2,"nfc1",100,(1,)),(3,"nfc1",100,(2,)),(4,"nfc1",100,(3,)),(5,"nfc2",100,(3,)),(6,"nfc1",100,(4,)),(7,"nfc2",100,(5,)),(8,"matcher1",30,(6,)),(9,"matcher2",30,(7,)),(10,"host",20,(8,9)),(11,"host",5,(10,))]

# task_list = []
# task_list.append(read1)
# task_list.append(write1)
# task_list.append(text1) 
# task_list.append(read1)
# task_list.append(write2)
# task_list.append(text1) 

# task_list = [
#     #[(任务标识)，(操作序号，操作资源，时间，前置任务依赖，(die,page)), (...))
#     ["读1",(1,"nfc1",200,(0,),(1,0)),(2,"arm",1,(1,)),(3,"host",20,(2,))],
#     ["读2",(1,"nfc2",200,(0,),(2,2)),(2,'arm',1,(1,)),(3,'host',20,(2,))],
#     ["读3",(1,"nfc2",200,(0,),(2,3)),(2,'arm',1,(1,)),(3,'host',20,(2,))],
#     ["读4",(1,"nfc2",200,(0,),(2,4)),(2,'arm',1,(1,)),(3,'host',20,(2,))],
#     ["写1",(1,"nfc1",200,(0,),(1,1)),(2,"arm",1,(1,)),(3,"host",20,(2,))],
#     ["写2",(1,"nfc1",200,(0,),(1,3)),(2,"arm",1,(1,)),(3,"host",20,(2,))],
#     ["写3",(1,"nfc1",200,(0,),(1,4)),(2,"arm",1,(1,)),(3,"host",20,(2,))],
#     ["写4",(1,"nfc2",200,(0,),(2,5)),(2,"arm",1,(1,)),(3,"host",20,(2,))],
#     ["文本",
#         (1,"host",20,(0,)),
#         (2,"nfc1",200,(1,),(1,2)),
#         (3,"arm",1,(2,)),
#         (4,"nfc1",200,(3,),(1,0)),
#         (5,"arm",1,(4,)),
#         (6,"arm",arm_time,(5,)),
#         (7,"nfc2",200,(3,),(2,0)),
#         (8,"arm",1,(7,)),
#         (9,"arm",arm_time,(8,)),
#         (10,"host",20,(6,9,))    
#         ]
# ]


task_list = [['读1', [1, 'host', 20, (0,)], [2, 'nfc0', 200, (1,), (0, 2097484)], [3, 'arm', 1, (2,)], [4, 'nfc1', 200, (3,), (1, 2097484)], [5, 'arm', 1, (4,)], [6, 'nfc0', 200, (5,), (0, 2097485)], [7, 'arm', 1, (6,)], [8, 'nfc1', 200, (7,), (1, 2097486)], [9, 'arm', 1, (8,)], [10, 'nfc0', 200, (9,), (0, 2097486)], [11, 'arm', 1, (10,)], [12, 'nfc1', 200, (11,), (1, 2097486)], [13, 'arm', 1, (12,)], [14, 'nfc0', 200, (13,), (0, 2097487)], [15, 'arm', 1, (14,)], [16, 'nfc1', 200, (15,), (1, 2097488)], [17, 'arm', 1, (16,)], [18, 'host', 20, (17,)]], ['读2', [1, 'host', 20, (0,)], [2, 'nfc0', 200, (1,), (0, 471228)], [3, 'arm', 1, (2,)], [4, 'nfc1', 200, (3,), (1, 471228)], [5, 'arm', 1, (4,)], [6, 'nfc0', 200, (5,), (0, 471229)], [7, 'arm', 1, (6,)], [8, 'nfc1', 200, (7,), (1, 471230)], [9, 'arm', 1, (8,)], [10, 'nfc0', 200, (9,), (0, 471230)], [11, 'arm', 1, (10,)], [12, 'nfc1', 200, (11,), (1, 471230)], [13, 'arm', 1, (12,)], [14, 'nfc0', 200, (13,), (0, 471231)], [15, 'arm', 1, (14,)], [16, 'nfc1', 200, (15,), (1, 471232)], [17, 'arm', 1, (16,)], [18, 'host', 20, (17,)]], ['文本1', [1, 'host', 20, (0,)], [2, 'nfc1', 200, (1,), (1, 4652)], [3, 'arm', 1, (2,)], [4, 'nfc1', 200, (3,), (1, 386)], [5, 'arm', 1, (4,)], [6, 'matcher', 150, (5,)], [7, 'nfc0', 200, (6,), (0, 4046)], [8, 'arm', 1, (7,)], [9, 'matcher', 150, (8,)], [10, 'host', 20, (6, 9)]], ['文本2', [1, 'host', 20, (0,)], [2, 'nfc1', 200, (1,), (1, 3416)], [3, 'arm', 1, (2,)], [4, 'nfc0', 200, (3,), (0, 4823)], [5, 'arm', 1, (4,)], [6, 'matcher', 150, (5,)], [7, 'nfc1', 200, (6,), (1, 8358)], [8, 'arm', 1, (7,)], [9, 'matcher', 150, (8,)], [10, 'host', 20, (6, 9)]], ['写1', [1, 'host', 20, (0,)], [2, 'nfc0', 200, (1,), (0, 2440480)], [3, 'arm', 1, (2,)], [4, 'nfc1', 200, (3,), (1, 2440480)], [5, 'arm', 1, (4,)], [6, 'nfc0', 200, (5,), (0, 2440481)], [7, 'arm', 1, (6,)], [8, 'nfc1', 200, (7,), (1, 2440482)], [9, 'arm', 1, (8,)], [10, 'nfc0', 200, (9,), (0, 2440482)], [11, 'arm', 1, (10,)], [12, 'nfc1', 200, (11,), (1, 2440482)], [13, 'arm', 1, (12,)], [14, 'nfc0', 200, (13,), (0, 2440483)], [15, 'arm', 1, (14,)], [16, 'nfc1', 200, (15,), (1, 2440484)], [17, 'arm', 1, (16,)], [18, 'host', 20, (17,)]], ['读3', [1, 'host', 20, (0,)], [2, 'nfc0', 200, (1,), (0, 470640)], [3, 'arm', 1, (2,)], [4, 'nfc1', 200, (3,), (1, 470640)], [5, 'arm', 1, (4,)], [6, 'nfc0', 200, (5,), (0, 470641)], [7, 'arm', 1, (6,)], [8, 'nfc1', 200, (7,), (1, 470642)], [9, 'arm', 1, (8,)], [10, 'nfc0', 200, (9,), (0, 470642)], [11, 'arm', 1, (10,)], [12, 'nfc1', 200, (11,), (1, 470642)], [13, 'arm', 1, (12,)], [14, 'nfc0', 200, (13,), (0, 470643)], [15, 'arm', 1, (14,)], [16, 'nfc1', 200, (15,), (1, 470644)], [17, 'arm', 1, (16,)], [18, 'host', 20, (17,)]], ['文本3', [1, 'host', 20, (0,)], [2, 'nfc1', 200, (1,), (1, 1436)], [3, 'arm', 1, (2,)], [4, 'nfc0', 200, (3,), (0, 3319)], [5, 'arm', 1, (4,)], [6, 'matcher', 150, (5,)], [7, 'nfc0', 200, (6,), (0, 189)], [8, 'arm', 1, (7,)], [9, 'matcher', 150, (8,)], [10, 'host', 20, (6, 9)]], ['文本4', [1, 'host', 20, (0,)], [2, 'nfc1', 200, (1,), (1, 2065)], [3, 'arm', 1, (2,)], [4, 'nfc1', 200, (3,), (1, 6730)], [5, 'arm', 1, (4,)], [6, 'matcher', 150, (5,)], [7, 'nfc1', 200, (6,), (1, 6169)], [8, 'arm', 1, (7,)], [9, 'matcher', 150, (8,)], [10, 'host', 20, (6, 9)]], ['读4', [1, 'host', 20, (0,)], [2, 'nfc0', 200, (1,), (0, 584680)], [3, 'arm', 1, (2,)], [4, 'nfc1', 200, (3,), (1, 584680)], [5, 'arm', 1, (4,)], [6, 'nfc0', 200, (5,), (0, 584681)], [7, 'arm', 1, (6,)], [8, 'nfc1', 200, (7,), (1, 584682)], [9, 'arm', 1, (8,)], [10, 'nfc0', 200, (9,), (0, 584682)], [11, 'arm', 1, (10,)], [12, 'nfc1', 200, (11,), (1, 584682)], [13, 'arm', 1, (12,)], [14, 'nfc0', 200, (13,), (0, 584683)], [15, 'arm', 1, (14,)], [16, 'nfc1', 200, (15,), (1, 584684)], [17, 'arm', 1, (16,)], [18, 'nfc0', 200, (17,), (0, 584684)], [19, 'arm', 1, (18,)], [20, 'host', 20, (19,)]], ['读5', [1, 'host', 20, (0,)], [2, 'nfc0', 200, (1,), (0, 2312048)], [3, 'arm', 1, (2,)], [4, 'nfc1', 200, (3,), (1, 2312048)], [5, 'arm', 1, (4,)], [6, 'nfc0', 200, (5,), (0, 2312049)], [7, 'arm', 1, (6,)], [8, 'nfc1', 200, (7,), (1, 2312050)], [9, 'arm', 1, (8,)], [10, 'nfc0', 200, (9,), (0, 2312050)], [11, 'arm', 1, (10,)], [12, 'nfc1', 200, (11,), (1, 2312050)], [13, 'arm', 1, (12,)], [14, 'nfc0', 200, (13,), (0, 2312051)], [15, 'arm', 1, (14,)], [16, 'nfc1', 200, (15,), (1, 2312052)], [17, 'arm', 1, (16,)], [18, 'nfc0', 200, (17,), (0, 2312052)], [19, 'arm', 1, (18,)], [20, 'host', 20, (19,)]]]








